package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.product.service.TestService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "测试接口")
@RestController
@RequestMapping("/admin/product/test")
public class TestController {

    private TestService testService;

    @Autowired
    public TestController(TestService testService) {
        this.testService = testService;
    }

    @GetMapping("/testLock")
    public Result testLock() {
        this.testService.testLock();
        return Result.ok();
    }

    //读写锁(读)
    @GetMapping("/read")
    public Result<String> read() {
        String msg = this.testService.readLock();
        return Result.ok(msg);
    }
    //读写锁(写)
    @GetMapping("/write")
    public Result<String> write() {
        String msg = this.testService.writeLock();
        return Result.ok(msg);
    }


}
